C++ Code Implementation
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
using namespace std;
int main() {
int cols, rows;
cout << "Enter number of columns: ";
cin >> cols;
cout << "Enter number of rows: ";
cin >> rows;
cin.ignore();
vector<string> headings(cols);
vector<vector<string>> data(rows, vector<string>(cols));
cout << "\nEnter headings:\n";
for (int i = 0; i < cols; ++i) {
cout << "Heading " << i + 1 << ": ";
getline(cin, headings[i]);
}
for (int i = 0; i < rows; ++i) {
cout << "\nEnter data for row " << i + 1 << ":\n";
for (int j = 0; j < cols; ++j) {
cout << headings[j] << ": ";
getline(cin, data[i][j]);
}
}
ofstream html("C:\\Users\\YourUsername\\Desktop\\html_output\\table.html");
html << "<html><head><title>Table</title></head><body>";
html << "<h2>Generated Table</h2><table border='1' cellpadding='5'>";
html << "<tr>";
for (const auto& h : headings)
html << "<th>" << h << "</th>";
html << "</tr>";
for (const auto& row : data) {
html << "<tr>";
for (const auto& cell : row)
html << "<td>" << cell << "</td>";
html << "</tr>";
}
html << "</table></body></html>";
html.close();
cout << "\nHTML file created on Desktop\\html_output folder.\n";
return 0;
}